<?php
/**
 * Created by PhpStorm.
 * User: cong.ding
 * Date: 2017/11/15
 * Time: 18:02
 */

include_once('./lib/QrReader.php');

include_once('common_util.php');

$base64_image_content =$_POST['img'];

log($base64_image_content) ;

//$output =json_encode(["data"=>$base64_image_content]);
//echo $output;

//if (preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result))
//{
$str = explode(',', $base64_image_content);
$qrcode = new QrReader(base64_decode($str[1]), QrReader::SOURCE_TYPE_BLOB);
$text = $qrcode->text();

$output = json_encode(["data" => $text]);
echo $output;

//}else{
//  echo '{"status":"preg error","data":"NO"}';
//}